﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/HomeMaster.Master" AutoEventWireup="true"
    CodeBehind="List.aspx.cs" Inherits="CSP.Web.MyHome.ServiceOrder.List" %>

<asp:Content ID="CSPHead" ContentPlaceHolderID="CSPHead" runat="server">
    <meta charset="utf-8">
    <title>订单管理-机构</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
</asp:Content>
<asp:Content ID="CSPStyleAndScript" runat="server" ContentPlaceHolderID="CSPStyleAndScript">
    <script src="/Scripts/UI/Expand/dialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.includeFile(['/Styles/lib/jquery-ui/jquery-ui-1.8.22.custom.css', '/scripts/ui/jquery/jquery.ui.core.js', '/scripts/ui/jquery/jquery.ui.datepicker.min.js', '/scripts/ui/lang/jquery.ui.datepicker-zh-CN.js']);
        function CancelOrder(orderNumber) {
            DialogMessage.ConfirmShow("提示", "确定要取消此订单？", function () {
                $.ajax({
                    type: "get",
                    dataType: "json",
                    //data: { OrderNumber: ordernumber, ShipmentID:shipmentID, Notes: notes, Action: "CancelShipmentByID" },
                    url: "List.aspx?cancelordernumber=" + orderNumber,
                    async: false,
                    cache: false,
                    error: function (result) {
                        result;
                    },
                    success: function (data, textStatus) {
                        data;
                        //执行成功
                        if (data.status == 1) {
                            DialogMessage.Show(1, data.msg, function () {
                                window.location.href = "List.aspx";
                            });
                        }
                        else if (data.status == 2)//警告
                        {
                            DialogMessage.Show(2, data.msg);
                        }
                        else {
                            DialogMessage.Show(0, data.msg);
                        }
                    }
                });
            });
        }

        function ConfirmOrder(orderNumber) {
            var confirmDiv = '<div title= "订单确认" ><p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>';
            confirmDiv += '<span>合作起始时间:</span><input type="text" id="Txt_ConfirmStartDate" value="" />至';
            confirmDiv += '<input type="text" id="Txt_ConfirmEndDate" value="" /><div class="error"></div>';
            var dialogObj = $(confirmDiv);
            var Txt_ConfirmStartDate = dialogObj.find("#Txt_ConfirmStartDate");
            var Txt_ConfirmEndDate = dialogObj.find("#Txt_ConfirmEndDate");

            Txt_ConfirmStartDate.datepicker({ beforeShow: function () {
                setTimeout(
                    function () {
                        $('#ui-datepicker-div').css("z-index", 15);
                    }, 100
                );
            }
            });

            Txt_ConfirmEndDate.datepicker({ beforeShow: function () {
                setTimeout(
                    function () {
                        $('#ui-datepicker-div').css("z-index", 15);
                    }, 100
                );
            }
            });

            dialogObj.dialog({
                resizable: false,
                width: 300,
                height: 140,
                modal: true,
                buttons: {
                    "订单确认": function () {

                        if (Txt_ConfirmStartDate.val() == "") {
                            Txt_ConfirmStartDate.next("div .error").html("确认起始时间不能为空");
                            Txt_ConfirmStartDate.focus();
                            return false;
                        }
                        else if (Txt_ConfirmEndDate.val() = "") {
                            Txt_ConfirmEndDate.next("div .error").html("确认的结束时间不能为空");
                            Txt_ConfirmEndDate.focus();
                            return false;
                        }
                        Txt_ConfirmStartDate.next("div .error").html();

                        var Txt_ConfirmStartDateValue = Txt_ConfirmStartDate.val();
                        var Txt_ConfirmEndDateValue = Txt_ConfirmEndDate.val();
                        $.ajax({
                            type: "get",
                            dataType: "json",
                            //data: { OrderNumber: ordernumber, ShipmentID:shipmentID, Notes: notes, Action: "CancelShipmentByID" },
                            url: "List.aspx?confirmordernumber=" + orderNumber + "&startdate=" + Txt_ConfirmStartDateValue + "&enddate=" + Txt_ConfirmEndDateValue,
                            async: false,
                            cache: false,
                            error: function (result) {
                                result;
                            },
                            success: function (data, textStatus) {
                                data;
                                //执行成功
                                if (data.status == 1) {
                                    DialogMessage.Show(1, data.msg, function () {
                                        window.location.href = "List.aspx";
                                    });
                                }
                                else if (data.status == 2)//警告
                                {
                                    DialogMessage.Show(2, data.msg);
                                }
                                else {
                                    DialogMessage.Show(0, data.msg);
                                }
                            }
                        });
                        $(this).dialog("close");
                    },
                    "取消": function () {
                        $(this).dialog("close");
                    }
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="CSPCrumbs" ContentPlaceHolderID="CSPCrumbs" runat="server">
    <div class="crumbs">
        <span>您当前所在的位置：</span> <a href="/">首页</a> &gt; <a href="/MyHome/ServiceOrder/List.aspx">我是服务者</a> &gt; <span>发布类型</span>
    </div>
    <!--crumbs-->
</asp:Content>
<asp:Content ID="CSPRight" runat="server" ContentPlaceHolderID="CSPRight">
    <div class="pr10">
        <div class="tabs tabs-home mt10">
            <div class="tabs-nd">
                <ul class="tabs-hd">
                    <li class="trigger current">我的合作订单</li>
                </ul>
            </div>
            <div class="tabs-bd order">
                <div class="tabs-panel">
                    <div class="thead mt10">
                        <asp:DropDownList ID="S_OrderTimeRegion" runat="server" AutoPostBack="true" OnSelectedIndexChanged="S_OrderTimeRegion_SelectedIndexChanged">
                            <asp:ListItem Value="0" Text="一个月内的合作"></asp:ListItem>
                            <asp:ListItem Value="1" Text="三个月内的合作"></asp:ListItem>
                            <asp:ListItem Value="2" Text="一年内的合作"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:DropDownList ID="S_OrderStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="S_OrderStatus_SelectedIndexChanged">
                            <asp:ListItem Value="" Text="全部订单"></asp:ListItem>
                            <asp:ListItem Value="" Text="全部订单"></asp:ListItem>
                            <asp:ListItem Value="0" Text="报名中"></asp:ListItem>
                            <asp:ListItem Value="1" Text="订单取消"></asp:ListItem>
                            <asp:ListItem Value="3" Text="预约成功"></asp:ListItem>
                        </asp:DropDownList>
                        <span class="order-search fr">
                            <input id="Txt_SearchValue" runat="server" type="text" class="text" placeholder="输入合作标题/合作编号/服务者名称">
                            <input type="submit" runat="server" onserverclick="Btn_Search_Click" class="submit"
                                value="查询">
                        </span>
                    </div>
                    <!--thead-->
                    <asp:Repeater ID="R_ConsumeOrder" ViewStateMode="Disabled" runat="server">
                        <HeaderTemplate>
                            <table class="table-style mtb15" width="100%" border="0" cellspacing="0" cellpadding="0">
                                <colgroup>
                                    <col width="100">
                                    <col width="190">
                                    <col width="130">
                                    <col width="120">
                                    <col width="90">
                                    <col width="80">
                                    <col width="80">
                                </colgroup>
                                <thead>
                                    <tr>
                                        <th scope="col">
                                            合作编号
                                        </th>
                                        <th align="left" scope="col">
                                            服务项目
                                        </th>
                                        <th align="left" scope="col">
                                            消费者名称
                                        </th>
                                        <th align="center" scope="col">
                                            预约时间
                                        </th>
                                        <th scope="col">
                                            总费用
                                        </th>
                                        <th scope="col">
                                            合作状态
                                        </th>
                                        <th scope="col">
                                            操作
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr class="bg">
                                <td height="80" align="center">
                                    <a href="Detail.aspx?ordernumber=<%#Eval("OrderNumber") %>">
                                        <%#Eval("OrderNumber") %></a>
                                </td>
                                <td>
                                    <h3 class="title">
                                        <a href="/detail/<%#Eval("ServiceInfoId") %>.shtml">
                                            <%#Eval("ServiceTitle") %></a></h3>
                                </td>
                                <td>
                                    <p class="company-name">
                                        <a href="#">
                                            <%#Eval("OrderUserName")%><img align="absmiddle" src="/images/evaluate/<%#GetCreditImgNameByUserName(Eval("OrderUserName").ToString()) %>"
                                                alt=""></a></p>
                                </td>
                                <td align="center">
                                    <%#Convert.ToDateTime(Eval("AppointmentDate")).ToString("yyyy-MM-dd") %>
                                </td>
                                <td align="center" class="price">
                                    <%#Convert.ToDecimal(Eval("TotalPrice")).ToString("0.00")%>元
                                </td>
                                <td align="center">
                                    <%#GetNameByOrderStatus(Eval("Status").ToString())%>
                                </td>
                                <td align="center" class="operate">
                                    <div style="display: <%#IsShowOperate(Convert.ToInt32(Eval("Status")))%>">
                                        <a href="Detail.aspx?ordernumber=<%#Eval("OrderNumber") %>">查看</a><br>
                                        <a href="javascript:CancelOrder('<%#Eval("OrderNumber") %>')" style="display: <%#IsShowCancelOrder(Convert.ToInt32(Eval("OrderRemind.RemindStatus")))?"block":"none"%>">
                                            取消</a><br>
                                        <a href="/MyHome/Credit/RatingConsume.aspx?ordernumber=<%#Eval("OrderNumber") %>"
                                            style="display: <%#IsShowRate(Convert.ToInt32(Eval("OrderRemind.RemindStatus")))?"block":"none"%>"
                                            class="ui-btn sl-rc"><span class="sl-rc-cnt major">评价</span></a> <a href="javascript:ConfirmOrder('<%#Eval("OrderNumber") %>')"
                                                class="ui-btn sl-rc" style="display: <%#IsShowCooperationConfirm(Convert.ToInt32(Eval("OrderRemind.RemindStatus")))?"block":"none"%>">
                                                <span class="sl-rc-cnt major">确认合作</span></a>
                                    </div>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            <tr>
                                <td colspan="4" style="text-align: center">
                                    <asp:Label ID="LB_Empty" runat="server" Text=""><%=R_ConsumeOrder.Items.Count == 0 ? "暂无数据" : ""%></asp:Label>
                                </td>
                            </tr>
                            </tbody> </table>
                        </FooterTemplate>
                    </asp:Repeater>
                    <div style="text-align:right;display:<%=R_ConsumeOrder.Items.Count == 0 ? "none" : "block"%>" align="right">
                        <!-- {{{ pagination -->
                        <CSP_U:CSPPager ID="U_OrderPager" OnIndexChange="U_OrderPager_IndexChange" runat="server" />
                        <!-- pagination }}} -->
                    </div>
                </div>
                <!--tabs-panel-->
            </div>
            <!--tabs-bd-->
        </div>
        <!--tabs-->
    </div>
</asp:Content>
